@extends('store::layout')
@push('styles')
    <link href="{{asset(config('store.theme.theme2').'/vendor/bootstrap/dataTables.bootstrap4.min.css')}}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
    <div class="row">
        <div class="col-12">
                @component('store::component.table.table_tpl')
                    @slot('page_title'){{$page_title}}@endslot
                    @slot('tool_l_btn')
                        @component('store::component.form.button')
                            @slot('elem') a @endslot
                            @slot('title') 添加商品 @endslot
                            @slot('size') md @endslot
                            @slot('icon') hcl-goods-add1 @endslot
                            @slot('href') {{route('Store_Goods_create')}} @endslot
                        @endcomponent
                    @endslot
                    @if($list->isNotEmpty())
                        @slot('table')
                            <table class="list table table-bordered table-striped">
                                <thead><tr role="row">
                                    <td>
                                    @component('store::component.checkbox')
                                        @slot('name') ids-all @endslot
                                    @endcomponent
                                    </td>
                                    <th>商品图片</th><th>商品名称</th>
                                    <th>价格</th><th>销售量</th><th>库存</th>
                                    <th>状态</th><th>操作</th>
                                </tr></thead>
                                <tbody>
                                @foreach($list as $goods)
                                    <tr role="row" class="odd">
                                        <td>
                                            @component('store::component.checkbox')
                                                @slot('name') id[] @endslot
                                                @slot('class') id @endslot
                                                @slot('value') {{$goods->id}} @endslot
                                            @endcomponent
                                        </td>
                                        <td><img style="height: 60px;" src="{{str2arr($goods->goods_images)[1]}}"></td>
                                        <td>{{$goods->goods_name}}</td>
                                        <td>{{$goods->price}}</td>
                                        <td>{{$goods->fact_sales_volume}}</td>
                                        <td>{{$goods->stock}}</td>
                                        <td>
                                            @if($goods->status!=-1)
                                                @component("store::component.switch")
                                                    @slot('on') 上架 @endslot
                                                    @slot('off') 下架 @endslot
                                                    @slot('params')
                                                        {"url":"{{route('Store_Goods_switchGoods',['goods_id'=>$goods->goods_id])}}"}
                                                    @endslot
                                                    @slot('checked') @if($goods->status == 1) checked @endif @endslot
                                                @endcomponent
                                             @else
                                                产品被强制下架
                                            @endif
                                        </td>
                                        <td>
                                            @component('store::component.form.button')
                                                @slot('elem') a @endslot
                                                @slot('title') 编辑商品 @endslot
                                                @slot('icon') hcl-edit @endslot
                                                @slot('href') {{route('Store_Goods_update',['goods_id'=>$goods->goods_id])}} @endslot
                                            @endcomponent
                                                @component('store::component.form.button')
                                                    @slot('elem') a @endslot
                                                    @slot('color') info @endslot
                                                    @slot('title') 商品详情 @endslot
                                                    @slot('icon') hcl-order-list @endslot
                                                    @slot('href') {{route('Store_Goods_detail',['goods_id'=>$goods->goods_id])}} @endslot
                                                @endcomponent
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        @endslot
                        @slot('page')
                            {{$list->links('store::public.pagination')}}
                        @endslot
                    @else
                        @slot('table')
                                @component('store::public.empty')
                                    @slot('info') 暂时没有商品信息 @endslot
                                @endcomponent
                            @endslot
                    @endif
                @endcomponent
        </div> <!-- end col -->
    </div>
@endsection

@push('scripts')
    <script src="{{asset(config('store.plugin').'/layui/check-all.js')}}"></script>
@endpush